#ifndef __NET_SIVNPDU_H__
#define __NET_SIVNPDU_H__


#include <stdbool.h>

#define PKT_HDR_SIZE (104+8*4)
#define PKT_PAGE_SIZE (1024)

typedef struct SPacket
{
	int				m_iLastUId;
	unsigned char *	m_pBuffer;		//缓冲指针
	unsigned int	m_Size;			//大小
	unsigned int	m_Length;		//数据长度
	unsigned int	m_RefCount;		//引用计数  ，每增加一个人数绑定包就+1
	void*			m_Mutex;		//互斥量  
	unsigned char	m_Header[PKT_HDR_SIZE];
	struct SPacket *m_pNext;

}SPacket;





typedef struct SIVnPdu
{
	struct dvrip* m_pIpHdr;
	void* m_pConn;
	char* m_pBuffer;/* 内部分析和打包缓冲，内部申请以及内部释放*/
	int m_iTotalLen;
	struct SPacket * m_pPacker;
	char m_stDVRIPHdr[32];

}SIVnPdu;


typedef struct 
{
	bool m_nested;	//!嵌套标志  ，暂时不需要使用
    unsigned int m_type;
    unsigned int m_len;
    unsigned char *	m_pBuffer;		//缓冲指针

}STlv;





bool Net_packetBody(struct SIVnPdu* P_SIVnPdu,char* pData, int iLen);
bool Net_ParseBody(struct SIVnPdu* P_SIVnPdu,char *pBuff, int iLen);
unsigned int SPacket_PutBuffer(SPacket *p_Packet,void * pdat, unsigned int dwLength);
void SPacket_Destory(SPacket **P_Pack);
void SIVnPdu_Init(SIVnPdu **P_SIVnPdu);
void SIVnPdu_Destory(SIVnPdu **P_SIVnPdu);
int STlv_Set(STlv *p_STlv,unsigned char* pbuf, unsigned int len, bool bTlv);
int STlv_Pack(STlv* p_STlv,unsigned char** pbuf, int *len);
void STIv_Destory(STlv **P_STlv);
void STlv_Init(STlv * P_STlv);











#endif


